package model

import "errors"

var ErrNotFound = errors.New("Rows selectd is zero")
var ErrNotUpdated = errors.New("Rows affected by update is zero")
var ErrNotDeleted = errors.New("Rows affected by delete is zero")

var IsConstraintError = errors.New("Constraint failed")
var IsValidationError = errors.New("Validation failed")
var IsNotSingular = errors.New("Name is not singular")

type AttributeAndOptions struct {
	Attribute *ProductAttribute
	Options   []*ProductAttributeOption
}

type VariationAndMeta struct {
	Variation *ProductVariation
	Meta      []*ProductVariationMetum
}

type ProductExtra struct {
	Meta                []*ProductMetum                   `json:"meta"`
	TermMeta            []*ProductTermMetum               `json:"termMeta"`
	CategoryIds         []int64                           `json:"cids"`
	TagIds              []int64                           `json:"tids"`
	Terms               []*ProductTermRelationship        `json:"terms"`
	Media               []*ProductAttachmentRelationship  `json:"attachments"`
	RelationShip        *ProductKnowledgeBaseRelationship `json:"relationship"`
	Attributes          []*AttributeAndOptions            `json:"attributes"`
	OptionKeyMap        map[int8]string                   `json:"optionKeyMap"` // 属性idx（临时值，未入库时无ID）=>属性值Key
	Variations          []*VariationAndMeta               `json:"variations"`
	Uri                 string                            `json:"uri"`
	UriTemplate         string                            `json:"uriTemplate"`
	ParentId            int64                             `json:"parentId"`
	DelRelationId       uint64                            `json:"delRelationId"`
	DelMetaIds          []uint64                          `json:"delMetaIds"`
	DelTermIds          []uint64                          `json:"delTermIds"`
	DelMediaIds         []uint64                          `json:"delMediaIds"`
	DelAttrOptIds       []uint64                          `json:"delAttrOptIds"`
	DelAttributeIds     []uint64                          `json:"delAttributeIds"`
	DelVariationIds     []uint64                          `json:"delVariationIds"`
	DelVariationMetaIds []uint64                          `json:"delVariationMetaIds"`
}

type ProductRel struct {
	Detail              *ProductDetail                      `json:"detail"`
	Meta                []*ProductMetum                     `json:"meta"`
	DelMetaIds          []uint64                            `json:"delMetaIds"`
	Media               []*ProductAttachmentRelationship    `json:"attachments"`
	DelMediaIds         []uint64                            `json:"delMediaIds"`
	CategoryIds         []uint64                            `json:"cids"`
	TagIds              []uint64                            `json:"tids"`
	Terms               []*ProductTermRelationship          `json:"terms"`
	DelTermIds          []uint64                            `json:"delTermIds"`
	RelationShips       []*ProductKnowledgeBaseRelationship `json:"relationships"`
	DelRelationIds      []uint64                            `json:"delRelationIds"`
	Attributes          []*AttributeAndOptions              `json:"attributes"`
	OptionKeyMap        map[int8]string                     `json:"optionKeyMap"`
	DelAttrOptIds       []uint64                            `json:"delAttrOptIds"`
	DelAttributeIds     []uint64                            `json:"delAttributeIds"`
	Variations          []*VariationAndMeta                 `json:"variations"`
	DelVariationIds     []uint64                            `json:"delVariationIds"`
	DelVariationMetaIds []uint64                            `json:"delVariationMetaIds"`
}

type ProductTermRel struct {
	Meta        []*ProductTermMetum              `json:"meta"`
	DelMetaIds  []uint64                         `json:"delMetaIds"`
	Media       []*ProductAttachmentRelationship `json:"media"`
	DelMediaIds []uint64                         `json:"delMediaIds"`
	Blacklist   []string                         `json:"blacklist"`
}

type AttributeRel struct {
	Blacklist []string `json:"blacklist"`
}
